<template>
  <div class="liveBottom">
    <div class="bottom_action">
      <div class="input">
        <!-- 功能菜单 -->
        <div class="input-icon" @click="clickMenu">
          <img src="@/assets/icons/menu.svg" alt="">
        </div>
        <!-- 输入框 -->
        <div class="input-text">
          <input type="text" v-model="inputValue" placeholder="说点什么~">
        </div>
        <!-- 发送按钮 -->
        <van-button plain round hairline type="primary" @click="sendInfo">发送</van-button>
      </div>
      <div class="like">
        <img src="@/assets/icons/like.svg" alt="" @click="clickLike">
        <canvas id="thumsCanvas" width="200" height="400" class="canvasBox"></canvas>
      </div>
    </div>

    <!-- 评论 -->
    <div class="comment">
      <div class="comment-list">
        <div class="tips">官方倡导绿色直播，对直播内容进行24小时在线巡查，一切黄赌毒内容将会封停账号。</div>
        <div v-for="item in 10" :key="item" class="comment-item">
          <div class="comment-item-avatar">
            <van-image round width="22" height="20" src="../../../public/msg/avatar2.jpeg" fit="cover" />
          </div>
          <div class="comment-item-text"><span style="color: #f9b611;">名字</span>
            这里是一段很长内容 这里是一段很长内容 这里是一段很长内容 这里是一段很长内容 这里是一段很长内容</div>
        </div>
      </div>
    </div>

    <!-- 功能按钮弹窗 -->
    <van-action-sheet v-model:show="menuShow" title="功能">
      <GridCard class="profile-action-card" :columnNum="3" :items="ActionCard"></GridCard>
    </van-action-sheet>
  </div>
</template>

<script setup>
// #region 评论
const inputValue = ref('')
function sendInfo() {
  console.log('发送评论')
}
// #endregion


// #region 点赞
import { ThumbsUpAni } from './canvas'
let thumsUpAni

onMounted(() => {
  thumsUpAni = new ThumbsUpAni()
})
function clickLike() {
  console.log('点赞');
  thumsUpAni.start()
}
// #endregion


//#region 功能按钮
const menuShow = ref(false)
function clickMenu() {
  console.log('点击功能按钮');
  menuShow.value = true
}

import { defineEmits } from 'vue'

const emit = defineEmits()

const ActionCard = reactive({
  Order: {
    text: '我的订单',
    svg: 'Order',
    to: '/my/orderList?status=0'
  },
  Withdrawal: {
    text: '清屏',
    svg: 'Withdrawal',
    func: () => {
      emit('hideUI') // 清屏
      menuShow.value = false //关闭弹层
    }
  },
  Friend: {
    text: '我的优惠券',
    svg: 'Friend',
  },
  Profit: {
    text: '我的邀请',
    svg: 'Profit',
  }
})
//#endregion


</script>

<style lang="scss" scoped>
.liveBottom {
  position: absolute;
  bottom: 0;
  z-index: 99;
  height: 40vh;
  display: flex;
  flex-direction: column-reverse; // 倒序
  width: 100%;
  font-size: 14px;

  .comment {
    flex: 1;
    overflow-y: auto;
    margin: 0 10px;
    color: #fff;
    font-size: 16px;
    // 顶部完全透明到20%完全不透明
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, #fff 20%);

    .comment-list {
      max-width: 80%;

      .tips {
        color: #f9b611;
        font-weight: 700;
        padding-top: 50px;
      }

      .comment-item {
        display: flex;
        background-color: rgba(0, 0, 0, 0.4);
        margin: 10px 0;
        padding: 5px;
        border-radius: 15px;
        width: fit-content; // 宽度根据内容自适应

        .comment-item-avatar {
          margin: 1px 5px 0 1px;
          display: flex;
          align-items: flex-start;
        }

        .comment-item-text {
          margin-right: 5px;
        }
      }
    }


    // #region 滚动条样式
    /* 滚动条整体样式 */
    &::-webkit-scrollbar {
      width: 12px;
      /* 滚动条宽度 */
    }

    /* 滚动条轨道样式 */
    &::-webkit-scrollbar-track {
      background-color: rgba($color: #000000, $alpha: 0);
      /* 轨道背景颜色 */
      border-radius: 10px;
      /* 轨道圆角 */
    }

    /* 滚动条滑块样式 */
    &::-webkit-scrollbar-thumb {
      background-color: rgba(0, 0, 0, 0.5);
      /* 滑块颜色 */
      border-radius: 6px;
      /* 滑块圆角 */
    }

    // #endregion
  }

  .bottom_action {
    display: flex;
    align-items: center;
    margin: 5px;

    .input {
      flex: 1;
      padding: 0px;
      margin-right: 5px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      background-color: rgba(0, 0, 0, 0.4);
      border-radius: 100px;
      color: #fff;

      .input-text {
        padding-left: 7px;
        flex: 1;
        font-size: 15px;

        input {
          border: none;
          background-color: transparent;
          width: 100%;

          &::placeholder {
            color: #fff;
          }
        }
      }

      .input-icon {
        display: flex;
        align-items: center;
        border-right: 3px solid #c6c5c5;

        img {
          width: 20px;
          height: 16px;
          margin: 0 10px 0 15px;
        }
      }
    }

    .like {
      display: flex;
      background-color: rgba(0, 0, 0, 0.4);
      border-radius: 100px;
      padding: 5px;

      img {
        width: 35px;
        height: 35px;
      }

      .canvasBox {
        width: 100px;
        height: 200px;
        position: absolute;
        bottom: 55px;
        right: -15px;
        background-color: transparent;
      }
    }

  }

}

:deep(.van-button) {
  height: 35px;
  margin: 5px 7px;
}
</style>